<template>
    <div class="Reflectedlist">
        <mt-header fixed title="审核体现列表">
            <mt-button icon="back" @click="back" slot="left"></mt-button>
        </mt-header>
        <mt-tab-container style="margin-top: 40px;" >
            <mt-tab-container-item>
                <a class="mint-cell" style="padding: 10px;" v-for="(n,index) in resultData">
                    <div class="mint-cell-left"></div>
                    <div class="mint-cell-wrapper">
                        <div class="mint-cell-title">
                            <span class="mint-cell-text">金额:{{n.money}}</span>
                            <span class="mint-cell-label">姓名:{{n.name}}</span>
                            <span class="mint-cell-label">电话:{{n.userMobile}}</span>
                        </div>
                        <div class="mint-cell-value" @click="process(n.crashId,1)">
                            <button class="mint-button mint-button--primary mint-button--small">
                                <label class="mint-button-text">通过</label></button>
                        </div>
                        <div class="mint-cell-value" @click="process(n.crashId,2)" style="margin-left: 10px;">
                            <button class="mint-button mint-button--danger mint-button--small">
                                <label class="mint-button-text">驳回</label></button>
                        </div>
                    </div>
                    <div class="mint-cell-right"></div>
                </a>
            </mt-tab-container-item>
        </mt-tab-container>
    </div>
</template>

<script>
    import {
            crashlist,
            crash,
            loading,
            back,
    } from '../common/api/api';
    import { Toast ,Indicator , MessageBox} from 'mint-ui';
    export default {
        name: 'Reflectedlist',
        data () {
            return {
                articles:[],
                createDialog: {
                    opened: false,
                    loading: false
                },
                resultData : null
            }
        },
        components: {
            //Hello
        },
        methods: {
            back : back,
            init : function () {
                var vm = this;
                const params = {

                }
                loading(true);
                crashlist(params, {
                    target: vm.createDialog
                })
                        .then((result) => {
                    console.log(result);
                vm.createDialog.opened = false;
                if(result.errno == 0){
                        loading(false);
                        vm.resultData = result.data.data;

                    }else{
                        loading(false);
                        Toast(data.errmsg);
                    }

                });
            },
            process : function (crashId,status) {
                var vm = this;
                const params = {
                    crashId : crashId,
                    status : status
                }
                if(status == 2){
                    MessageBox.prompt('拒绝理由').then(({ value, action }) => {
//                            console.log(value);
//                            console.log(action)
                        if(value == null || value == ""){
                            Toast("请输入拒绝理由");
                        }else{
                            params.content = value;
                            vm.requetCrash(params)
                            console.log(params);
                        }
                    });
                }else{
                    vm.requetCrash(params)
                }


            },
            requetCrash : function (params) {
                var vm = this;
                loading(true);
                crash(params, {
                    target: vm.createDialog
                }).then((result) => {
                    console.log(result);
                    vm.createDialog.opened = false;
                    if(result.errno == 0){
                        loading(false);
                        vm.init();

                    }else{
                        loading(false);
                        Toast(data.errmsg);
                    }

                });
            }
        },
        created() {
            this.init()
        },
    }
</script>
